package thread;
/*通过一个取款案例演示多线程并发安全问题

 */
public class Bank {
    public int account = 20000;

    public synchronized int getAccount() {
        return account;
    }

    public void setAccount(int account) {
        this.account = account;
    }

    public synchronized Boolean getMoney(int money){
        if (account>= money){
            account-=money;
            return true;
        }
        return false;
    }
}
